package org.tnc.budget.model;

import static javax.persistence.GenerationType.IDENTITY;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Proxy;
import org.tnc.model.User;

/**
 * BudgetCenter entity. @author MyEclipse Persistence Tools
 */
@Entity
@Proxy(lazy=false)
@Table(name = "budget_center", catalog = "tnc", uniqueConstraints = {
		@UniqueConstraint(columnNames = "bc_name"),
		@UniqueConstraint(columnNames = "bc_id") })
public class BudgetCenter implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 8602394148956994077L;
	private Integer id;
	private String bcName;
	private User user;
	private String bcDec;
	private String bcPeople;
	private Date bcDate;
	private String bcId;
	private Boolean bcValid;
	private Set<EventTable> eventTables = new HashSet<EventTable>(0);
	private Boolean vacation;

	// Constructors

	/** default constructor */
	public BudgetCenter() {
	}

	/** minimal constructor */
	public BudgetCenter(User user, String bcName, String bcPeople,
			Timestamp bcDate, String bcId, Boolean bcValid) {
		this.bcName = bcName;
		this.user = user;
		this.bcPeople = bcPeople;
		this.bcDate = bcDate;
		this.bcId = bcId;
		this.bcValid = bcValid;
	}

	/** full constructor */
	public BudgetCenter(User user, String bcName, String bcDec,
			String bcPeople, Timestamp bcDate, String bcId, Boolean bcValid,
			Set<EventTable> eventTables) {
		this.bcName = bcName;
		this.user = user;
		this.bcDec = bcDec;
		this.bcPeople = bcPeople;
		this.bcDate = bcDate;
		this.bcId = bcId;
		this.bcValid = bcValid;
		this.eventTables = eventTables;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "bc_duty", nullable = false)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "bc_name", unique = true, nullable = false)
	public String getBcName() {
		return this.bcName;
	}

	public void setBcName(String bcName) {
		this.bcName = bcName;
	}

	@Column(name = "bc_dec", length = 65535)
	public String getBcDec() {
		return this.bcDec;
	}

	public void setBcDec(String bcDec) {
		this.bcDec = bcDec;
	}

	@Column(name = "bc_people", nullable = false, length = 100)
	public String getBcPeople() {
		return this.bcPeople;
	}

	public void setBcPeople(String bcPeople) {
		this.bcPeople = bcPeople;
	}

	@Column(name = "bc_date", nullable = false, length = 0)
	public Date getBcDate() {
		return this.bcDate;
	}

	public void setBcDate(Date bcDate) {
		this.bcDate = bcDate;
	}

	@Column(name = "bc_id", unique = true, nullable = false, length = 100)
	public String getBcId() {
		return this.bcId;
	}

	public void setBcId(String bcId) {
		this.bcId = bcId;
	}

	@Column(name = "bc_valid", nullable = false)
	public Boolean getBcValid() {
		return this.bcValid;
	}

	public void setBcValid(Boolean bcValid) {
		this.bcValid = bcValid;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "budgetCenter")
	public Set<EventTable> getEventTables() {
		return this.eventTables;
	}

	public void setEventTables(Set<EventTable> eventTables) {
		this.eventTables = eventTables;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BudgetCenter other = (BudgetCenter) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	@Column(name = "bc_vacation", nullable = true)
	public Boolean getVacation() {
		return vacation;
	}

	public void setVacation(Boolean vacation) {
		this.vacation = vacation;
	}

}